﻿using PmSoft.Utilities.Sm4;
using Newtonsoft.Json;
using System.Web;

namespace ManagementApi.Models.BankTransfer;

public class EncryptMess<T>
{
    /// <summary>
    /// Sm4加密后的数据
    /// </summary>
    public string Data { get; set; } = string.Empty;

    /// <summary>
    /// 获取加密后的参数
    /// </summary>
    /// <returns></returns>
    public T? GetParame()
    {
        string? encData = HttpUtility.UrlDecode(Sm4Crypto.DecryptCBC(new Sm4Crypto { Data = Data }));
        if (string.IsNullOrEmpty(encData))
            return default;
        return JsonConvert.DeserializeObject<T>(encData);
    }
}